package com.itheima.test0909.test04;

public class QuickSort {
    public static void main(String[] args) {
        int[] arr = {6,9,5,1,4,3,7,8,10,2};
        testSort(arr,0,arr.length-1);

    }

    public static void testSort(int[] arr,int left,int right){
        if (right<left){
            return;
        }

        int left0 = left;
        int right0 = right;

        int baseNum = arr[left0];

        while (left != right){
            while (arr[right] >= baseNum && right > left){
                right--;
            }
            while (arr[left] <= baseNum && right > left){
                left++;
            }
            int temp = arr[left];
            arr[left] = arr[right];
            arr[right] = temp;
        }
        int temp = arr[left0];
        arr[left0] = arr[left];
        arr[left] = temp;
        testSort(arr,left0,left-1);
        testSort(arr,left+1,right0);
    }

}
